<!-- components/ModifySkuDialog.vue -->
<template>
  <el-dialog v-model="dialogFormVisible" title="修改SKU" width="500">
    <el-form :model="form">
      <el-form-item label="SKU ID" :label-width="formLabelWidth">
        <el-input v-model="form.id" autocomplete="off" disabled />
      </el-form-item>
      <el-form-item label="SKU名称" :label-width="formLabelWidth">
        <el-input v-model="form.name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="SKU数量" :label-width="formLabelWidth">
        <el-input v-model="form.num" autocomplete="off" />
      </el-form-item>
      <el-form-item label="SKU价格" :label-width="formLabelWidth">
        <el-input v-model="form.price" autocomplete="off" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="handleConfirm">
          确认
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'

const dialogFormVisible = ref(false)
const formLabelWidth = '140px'

const form = reactive({
  id: '',
  name: '',
  num: '',
  price: ''
})

// 显示编辑表单弹窗
const showEditFormDialog = (rowData: { id: any; name: any; num: any; price: any }) => {
  dialogFormVisible.value = true
  // 填充表单数据
  Object.assign(form, {
    id: rowData.id || '',
    name: rowData.name || '',
    num: rowData.num || '',
    price: rowData.price || ''
  })
}

// 确认修改
const handleConfirm = () => {
  // 这里可以处理确认逻辑
  console.log('修改数据:', form)
  dialogFormVisible.value = false
}

defineExpose({
  showEditFormDialog
})
</script>